#!/bin/bash

tar cfp /tmp/bak $(find . -type f -name '*.java');

for src in $(egrep -v '#' sources)
do
 pkgclass=$(echo $src | sed 's%/%.%g; s%%\.java%;')
 classname=$(echo $src | sed 's%.*/%%; s%%\.java%;')
 for dep in $(egrep ${pkgclass} $(find . -type f -name '*.java') | sed 's/:.*//' | sort -u )
 do
  if cat $dep | sed "s%${pkgclass}%${classname}%g;" > /tmp/tmp
  then
   touch -r $dep /tmp/tmp
   cp -p /tmp/tmp $dep
   ls -l $dep | sed "s%^%${classname}: %;"
  else
   exit 1
  fi
 done
done
